# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=lz4
pkgver=1.9.4
pkgrel=5
pkgdesc="LZ4 is lossless compression algorithm with fast decoder @ multiple GB/s per core."
url="https://github.com/lz4/lz4"
arch="all"
license="BSD-2-Clause AND GPL-2.0-only"
checkdepends="diffutils"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc $pkgname-libs $pkgname-tests:tests"
source="$pkgname-$pkgver.tar.gz::https://github.com/lz4/lz4/archive/v$pkgver.tar.gz"

# secfixes:
#   1.9.3-r1:
#     - CVE-2021-3520
#   1.9.2-r0:
#     - CVE-2019-17543

build() {
	export CFLAGS="$CFLAGS -O2 -flto=auto"
	export CPPFLAGS="$CPPFLAGS -O2 -flto=auto"
	make PREFIX="/usr"
}

check() {
	make check
}

package() {
	make PREFIX="/usr" DESTDIR="$pkgdir" install

	(
		cd tests/
		rm -f ./*.c COPYING Makefile .gitignore
	)
	mkdir -p "$pkgdir"/usr/share/$pkgname
	cp -rf tests "$pkgdir"/usr/share/$pkgname/
}

tests() {
	pkgdesc="$pkgdesc (tests)"
	amove usr/share/$pkgname
}

sha512sums="
043a9acb2417624019d73db140d83b80f1d7c43a6fd5be839193d68df8fd0b3f610d7ed4d628c2a9184f7cde9a0fd1ba9d075d8251298e3eb4b3a77f52736684  lz4-1.9.4.tar.gz
"
